package com.yogee.topseller.activity.tianyan;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.yogee.core.http.listener.HttpOnNextListener;
import com.yogee.core.http.subscribers.BaseSubscriber;
import com.yogee.core.utils.ToastUtils;
import com.yogee.topseller.R;
import com.yogee.topseller.activity.base.HttpActivity;
import com.yogee.topseller.adapter.BzxrAdapter;
import com.yogee.topseller.bean.BzxrBean;
import com.yogee.topseller.bean.DetailBean;
import com.yogee.topseller.bean.GphqBean;
import com.yogee.topseller.http.HttpManager;
import com.yogee.topseller.layout.TitleLayout;
import com.yogee.topseller.utils.AppUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class GphqDetailActivity extends HttpActivity {

    @BindView(R.id.add_card_titlelayout)
    TitleLayout titlelayout;

    @BindView(R.id.tv_time)
    TextView tv_time;
    @BindView(R.id.tv_value1)
    TextView tv_value1;
    @BindView(R.id.tv_value2)
    TextView tv_value2;
    @BindView(R.id.tv_value3)
    TextView tv_value3;
    @BindView(R.id.tv_value4)
    TextView tv_value4;
    @BindView(R.id.tv_value5)
    TextView tv_value5;
    @BindView(R.id.tv_value6)
    TextView tv_value6;
    @BindView(R.id.tv_value7)
    TextView tv_value7;
    @BindView(R.id.tv_value8)
    TextView tv_value8;
    @BindView(R.id.tv_value9)
    TextView tv_value9;
    @BindView(R.id.tv_value10)
    TextView tv_value10;
    @BindView(R.id.tv_value11)
    TextView tv_value11;
    @BindView(R.id.tv_value12)
    TextView tv_value12;
    @BindView(R.id.tv_value13)
    TextView tv_value13;
    @BindView(R.id.tv_value14)
    TextView tv_value14;
    @BindView(R.id.tv_value15)
    TextView tv_value15;
    @BindView(R.id.tv_value16)
    TextView tv_value16;
    @BindView(R.id.tv_value17)
    TextView tv_value17;
    @BindView(R.id.tv_value18)
    TextView tv_value18;
    @BindView(R.id.tv_value19)
    TextView tv_value19;
    @BindView(R.id.tv_value20)
    TextView tv_value20;
    @BindView(R.id.tv_value21)
    TextView tv_value21;
    @BindView(R.id.sv_one)
    ScrollView sv_one;
    @BindView(R.id.id_empty_view)
    View id_empty_view;
    @BindView(R.id.iv_empty)
    ImageView iv_empty;

    private String type = "";
    private String companyId="";
    private String cmpanyType = "";
    private String proId="";

    @Override
    protected int getLayoutId() {
        return R.layout.activity_detail_gphq;
    }

    @Override
    protected void initView() {
        titlelayout.setActivity(this);
        titlelayout.setTitle(getIntent().getStringExtra("title"));
        cmpanyType= getIntent().getStringExtra("cmpanyType");
        type =  getIntent().getStringExtra("type");
        companyId = getIntent().getStringExtra("companyId");
        proId = getIntent().getStringExtra("proId");
        iv_empty.setImageResource(R.drawable.nodata1);
//        setData();
//        (GphqBean.Res) getIntent().getSerializableExtra("info")
        initBzxr();
    }


    private void initBzxr(){
        HttpManager.getInstance().eyeCheckGPHQ(companyId,type, AppUtil.getUserId(GphqDetailActivity.this),cmpanyType,proId).compose(this.bindRecycler()).subscribe(new BaseSubscriber(new HttpOnNextListener<GphqBean>() {
            @Override
            public void onNext(GphqBean o) {
                if(o.getEyeCheck().getError_code()==0){
                    sv_one.setVisibility(View.VISIBLE);
                    id_empty_view.setVisibility(View.GONE);
//                    detailAdapter.addData(o.getEyeCheck().getResult().getItems());
                    setData(o.getEyeCheck().getResult());
                }else{
                    id_empty_view.setVisibility(View.VISIBLE);
//                    ToastUtils.showToast(GphqDetailActivity.this,o.getEyeCheck().getReason());
                }

            }
        }, this));
    }

    private void setData(GphqBean.Res info){
        tv_time.setText(info.getTimeshow());
        tv_value1.setText(info.getStockcode());
        tv_value2.setText(info.getStockname());
        tv_value3.setText(info.getStockType());
        tv_value4.setText(info.getFvaluep());
        tv_value5.setText(info.getTvalue());
        tv_value6.setText(info.getFlowvalue());
        tv_value7.setText(info.getFlowvalue());
        tv_value8.setText(info.getTvaluep());
        tv_value9.setText(info.getTopenprice());
        tv_value10.setText(info.getTamount());
        tv_value11.setText(info.getTrange());
        tv_value12.setText(info.getThighprice());
        tv_value13.setText(info.getTamounttotal());
        tv_value14.setText(info.getTchange());
        tv_value15.setText(info.getTlowprice());
        tv_value16.setText(info.getPprice());
        tv_value17.setText(info.getTmaxprice());
        tv_value18.setText(info.getTminprice());
        tv_value19.setText(info.getHexm_curPrice());
        tv_value20.setText(info.getHexm_float_price());
        tv_value21.setText(info.getHexm_float_rate());

    }

}
